<?php  //文章列表页
if(!defined('EMLOG_ROOT')) {exit('error!');} ?>
</head>
<body class="archive category category-front category-130">
<?php blog_head(); ?>
<section class="container">
<div class="content-wrap">
<?php doAction('index_loglist_top'); ?>
	<div class="content">
		<div class="pagetitle">
			<h2>
            <?php if ($params[1]=='sort'){ ?>
		分类：<?php echo $sortName;?>
<?php }elseif ($params[1]=='tag'){ ?>
		标签:<?php echo htmlspecialchars(urldecode($params[2]));?>
<?php }elseif($params[1]=='author'){ ?>
		作者：<?php echo blog_author($author);?>
<?php }elseif($params[1]=='keyword'){ ?>
       关键词：<?php echo htmlspecialchars(urldecode($params[2]));?>
<?php }elseif($params[1]=='record'){ ?>
       时间：<?php echo substr($params[2],0,4).'年'.substr($params[2],4,2).'月';?><?php if(strlen($params[2])=="8"){echo substr($params[2],6,2).'日';}?>
<?php }else{?>文章列表<?php }?>
            </h2>
		</div>
       <?php if (!empty($logs)):foreach($logs as $value): ?> 
       <article class="excerpt">
       <a class="focus" href="<?php echo $value['log_url']; ?>">
       <?php $thum_src = getThumbnail($value['logid']);$imgFileArray = glob("content/templates/static/img/random/*.*");$imgsrc = preg_match_all("|<img[^>]+src=\"([^>\"]+)\"?[^>]*>|is", $value['content'], $img);$imgsrc = !empty($img[1]) ? $img[1][0] : ''; $imgNum = count($img[1]);?> 
	   <?php if ($thum_src):?> 
<img src="<?php echo $thum_src; ?>" class="thumb"style="display: inline;"/>  
<?php elseif($imgsrc): ?>
<img src="<?php echo $imgsrc; ?>" class="thumb"style="display: inline;"/>  
<?php else: ?>
<img src="<?php echo BLOG_URL; ?><?php echo $imgFileArray[array_rand($imgFileArray)]; ?>" class="thumb" style="display: inline;">  
<?php endif; ?></a>
<header><?php blog_sort($value['logid']); ?> 
<h2><a href="<?php echo $value['log_url']; ?>" title="<?php echo $value['log_title']; ?>"><?php echo $value['log_title']; ?></a><?php global $timezone;if(time() - $value['date'] < 172800 - $timezone*3600){echo '<small style="color:red">New</small>';}?>
<?php if ($imgsrc):?><small>
        <i class="icon-picture"></i><?php echo $imgNum;?></small>
        <?php endif;?></h2>
</header>
<p class="meta">
        <time><i class="icon-calendar"></i> <?php echo gmdate('Y-n-j G:i', $value['date']); ?></time><span class="pv"><i class="icon-eye-open"></i> 阅读（<?php echo $value['views']; ?>）</span><i class="icon-comment" ></i> <a class="pc" href="">评论(<?php echo $value['comnum']; ?>)</a>
		</p>
<p class="note"><?php echo $value['log_description'] = handlearticledes(subString(trim(strip_tags($value['log_description'])), 0,100));?>...</p></article>
        <?php endforeach;else:?>
       <header class="article-header">
	<h1 class="article-title">sorry！没有找到关 <?php if ($params[1]=='sort'){ ?>
		分类：<?php echo $sortName;?>
<?php }elseif ($params[1]=='tag'){ ?>
		标签:<?php echo htmlspecialchars(urldecode($params[2]));?>
<?php }elseif($params[1]=='author'){ ?>
		作者：<?php echo blog_author($author);?>
<?php }elseif($params[1]=='keyword'){ ?>
       关键词：<?php echo htmlspecialchars(urldecode($params[2]));?>
<?php }elseif($params[1]=='record'){ ?>
       时间：<?php echo substr($params[2],0,4).'年'.substr($params[2],4,2).'月';?><?php if(strlen($params[2])=="8"){echo substr($params[2],6,2).'日';}?>
<?php }else{?>文章列表<?php }?>的文章</h1>
	  </header>
      <article class="article-content">
        <?php if(ROLE == 'admin' || ROLE == 'writer'): ?>
        <a href="<?php echo BLOG_URL; ?>admin/write_log.php">点击这里发布您的第一篇文章</a>
        <?php else :?>

<?php  //用户注册
if(!defined('EMLOG_ROOT')) {exit('error!');}
$username = isset($_POST['username']) ? addslashes(trim($_POST['username'])) : '';
$password = isset($_POST['password']) ? addslashes(trim($_POST['password'])) : '';
$password2 = isset($_POST['password2']) ? addslashes(trim($_POST['password2'])) : '';

if($username && $password && $password2 ){
	$User_Model = new User_Model();
		if(!$User_Model -> isUserExist($username)){
			$hsPWD = new PasswordHash(8, true);
			$password = $hsPWD->HashPassword($password);
			$User_Model->addUser($username, $password, 'writer', 'y');
			$CACHE->updateCache();
			echo'<script>alert("注册成功！点击确定进入后台登录吧"); window.location.href="'.BLOG_URL.'admin/"</script>';
		}else{
			echo'<script>alert("sorry！这个用户名太热了！");</script>';
		}
};
?>
<div class="box" style="padding:20px;">
<p>看来小站还没有作者在此处发表文章，使用下面的注册注册本站会员并发表你的第一篇文章吧！ </p>
<p></p>
<div class="inner">
		<table align="center">
			<form action="" method="post" name="reg" id="reg" onSubmit="return checkReg();">
			<tr>
				<td align="right">用户名：</td><td><input name="username" class="usr" ></td><td> <span class="info">* 必填，大于等于5位</span></td>
			</tr>
			<tr>
				<td align="right">密码：</td><td><input name="password" type="password"></td><td> <span class="info">* 必填，大于等于5位</span></td>
			</tr>
			<tr>
				<td align="right">重复密码：</td><td><input name="password2" type="password"></td><td> <span class="info">* </span></td>
			</tr>
			<tr>
				<td align="right"></td><td><input type="submit" value="确认注册" class="btn btn-primary btn-sm"> <input type="reset" value="重置" class="btn btn-default btn-sm"></td><td></td>
			</tr>
			<tr>
				<td></td><td class="bot"><a href="<?php echo BLOG_URL;?>" title="返回首页">网站首页</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="<?php echo BLOG_URL;?>admin/" title="前往登录">已有账号？</a></td><td></td>
			</tr>
			</form>
		</table>
<script type="text/javascript">
function checkReg(){
	var usrName = $("input[name=username]").val().replace(/(^\s*)|(\s*$)/g, "");
	var pwd = $("input[name=password]").val().replace(/(^\s*)|(\s*$)/g, "");
	var pwd2 = $("input[name=password2]").val().replace(/(^\s*)|(\s*$)/g, "");
	if(usrName.match(/\s/) || pwd.match(/\s/)){
		alert("用户名和密码中不能有空格");
		return false;
	}
	if(usrName == '' || pwd == '' ){
		alert("用户名、密码不能为空！");
		return false;
	}
	if(usrName.length < 5 || pwd.length < 5){
		alert("用户名和密码都不能小于5位！");
		return false;
	}
	else if(pwd != pwd2){
		alert("两次输入密码不相等！");
		return false;
	}
}
</script>
	</div>
</div>
<?php endif;?></article>
        <?php endif;?>
		<div class="pagination">
			<div class="pagenav">
				<?php echo $page_url;?>
			</div>
		</div>
	</div>
</div>
<?php include View::getView('side2');?>
﻿</section>
<?php include View::getView('footer');?>